package com.yangjun.controller.scheduled;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.google.common.collect.Maps;
import com.yangjun.dao.mybatis.mapper.scheduled.LogAnalysisMapper;
import com.yangjun.entity.scheduled.AdVisitEffectReport;
import com.yangjun.entity.scheduled.AppRecommendReport;
import com.yangjun.entity.scheduled.WebSearchKeyWordAskReport;
import com.yangjun.utils.AjaxJson;

@RestController
@RequestMapping("/logReport")
public class LogAnalysisReportController {
	
	@Autowired
	public LogAnalysisMapper mapper;
	
	
	
	/**
	 * http://192.168.7.32:8080/logReport/webSearchKeyWordAsk
	 * @param response
	 * @return
	 */
	
	@RequestMapping("/webSearchKeyWordAsk")
	@ResponseBody
	public AjaxJson webSearchKeyWordAsk(HttpServletResponse response) {
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		AjaxJson j = new AjaxJson();
		Map<String, Object> attributes = Maps.newHashMap();
		
		List<WebSearchKeyWordAskReport> webSearchKeyWordAsk = mapper.webSearchKeyWordAsk();
		attributes.put("keywordAsk", webSearchKeyWordAsk);
		j.setAttributes(attributes);
		return j;
	}
	
	
	
	@RequestMapping("/adVisitEffect")
	@ResponseBody
	public AjaxJson adVisitEffect(HttpServletResponse response) {
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		AjaxJson j = new AjaxJson();
		Map<String, Object> attributes = Maps.newHashMap();
		
		List<AdVisitEffectReport> adVisitEffect = mapper.adVisitEffect();
		attributes.put("adVisitEffect", adVisitEffect);
		j.setAttributes(attributes);
		return j;
	}
	
	
	
	@RequestMapping("/appRecommend")
	@ResponseBody
	public AjaxJson appRecommend(HttpServletResponse response) {
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		AjaxJson j = new AjaxJson();
		Map<String, Object> attributes = Maps.newHashMap();
		
		List<AppRecommendReport> appRecommend = mapper.appRecommend();
		attributes.put("appRecommend", appRecommend);
		j.setAttributes(attributes);
		return j;
	}

}
